package GUI;

import Listeners.CloseBookInfoFrame;

import javax.swing.*;
import java.awt.*;

/**
 *
 */
public class BookInfoFrame extends JFrame{

    static JFrame bookInfo = new JFrame("Book Information");

    JPanel top = new JPanel(new GridLayout(0,2));
    JPanel content = new JPanel(new GridLayout(6,1));
    JPanel bottom = new JPanel(new GridLayout(0,2));
    JButton buy = new JButton("Buy Book");
    JButton close = new JButton("Close");

    public BookInfoFrame(){

        setup();

       bookInfo.setSize(400,500);

       bookInfo.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

       bookInfo.setLocationRelativeTo(null);

       bookInfo.setVisible(true);

    }
    private void setup(){

        close.addActionListener(new CloseBookInfoFrame());

        JLabel bName = new JLabel("     Book Name");
        bName.setFont(new Font("Calibri", Font.BOLD,24));
        bName.setForeground(Color.BLUE);

        JLabel bAuthor = new JLabel("     Book Auhtor");
        bName.setFont(new Font("Calibri", Font.BOLD,22));
        bName.setForeground(Color.BLUE);

        JLabel bCategory = new JLabel("     Category");
        bName.setFont(new Font("Calibri", Font.BOLD,20));
        bName.setForeground(Color.BLUE);

        JLabel bISBN = new JLabel("     Book ISBN");
        bName.setFont(new Font("Calibri", Font.BOLD,20));
        bName.setForeground(Color.BLUE);

        JLabel bYear = new JLabel("     Book Year");
        bName.setFont(new Font("Calibri", Font.BOLD,20));
        bName.setForeground(Color.BLUE);

        JLabel bPrice = new JLabel("     Book Price");
        bName.setFont(new Font("Calibri", Font.BOLD,20));
        bName.setForeground(Color.BLUE);

       /* bName.setHorizontalAlignment(SwingConstants.RIGHT);
        bAuthor.setHorizontalAlignment(SwingConstants.RIGHT);
        bCategory.setHorizontalAlignment(SwingConstants.RIGHT);
        bISBN.setHorizontalAlignment(SwingConstants.RIGHT);
        bYear.setHorizontalAlignment(SwingConstants.RIGHT);
        bPrice.setHorizontalAlignment(SwingConstants.RIGHT);   */

        top.add(bName);

        content.add(bAuthor);
        content.add(bCategory);
        content.add(bISBN);
        content.add(bYear);
        content.add(bPrice);

        bottom.add(buy);
        bottom.add(close);


        bookInfo.add(top,BorderLayout.NORTH);
        bookInfo.add(content,BorderLayout.CENTER);
        bookInfo.add(bottom,BorderLayout.SOUTH);

    }
    public static void closeBookInfo(){
        bookInfo.dispose();
    }

}
